3 [ "$include_upload" ] && return 0
8 local boundary line length=0
10 [ ! "${CONTENT_TYPE}" -o "${CONTENT_TYPE##multipart/form-data;*}" ] && return 1
12 boundary="${CONTENT_TYPE#*; boundary=}"
13 boundary="${boundary%%;*}"
15 while read -r line; do
16 length="$(( length + ${#line} + 1))"
17 [ "${line%${CR}}" = "--$boundary" ] && break
19 while read -r line; do
20 length="$(( length + ${#line} + 1))"
21 [ ! "${line%${CR}}" ] && break \
25 printf "%i\n" "$(( CONTENT_LENGTH - length ))" >"${file}.upload"
26 head -c "$(( CONTENT_LENGTH - length ))" \
28 # print lines until boundary ( = actual file upload)
30 /^--'"${boundary}"'(--)?\r?$/!bFILE;
31 # discard remaining lines
34 truncate -s $(( $(stat -c %s -- "$file") -2 )) -- "$file"
35 rm -- "${file}.upload"
38 frame_uploadprogress() {
39 printf '<!DOCTYPE HTML>
41 <title>Upload Progress</title>
42 <link rel="stylesheet" type="text/css" href="%s/rawnet.css" />
43 </head><body id=uploadprogress>
45 printf '<div class=progress><div class=bar style="width: 0%%;"></div><div class=count>%i / %i</div></div>\n' 0 0
46 while [ ! -f "${VIDEO_FILE}" -a ! -f "${VIDEO_FILE}.upload" ]; do
49 read size <"${VIDEO_FILE}.upload"
50 while [ -f "${VIDEO_FILE}.upload" ]; do
51 stat="$(stat -c %s "$VIDEO_FILE" 2>&-)"
52 printf '<div class=progress><div class=bar style="width:%i%%;"></div><div class=count>%iMB / %iMB</div></div>\n' \
53 "$(( stat * 100 / size ))" "$((stat / 1048576))" "$((size / 1048576))"
56 printf '<span class=progress><div class=bar style="width:100%%;"></div><div class=count>Ready!</div></span>\n'
57 printf '</body></html>'